﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EventReminder.Server
{
    public class EventReminder
    {
        int _eventid;
        DateTime _eventdate_time;
        string _title;
        string _description;
        List<string> _emaillist;
        string _reminder;
        bool _followup;
        DateTime _remindersent;
        DateTime _nextreminder;
        int _userid;

        public EventReminder()
        {
            _emaillist = new List<string>();
        }

        public EventReminder(int id, DateTime date, string title, string desc, List<string> email, string reminder, bool followup, int uid)
        {
            _eventid = id;
            _eventdate_time = date;
            _title = title;
            _description = desc;
            _emaillist = email;
            _reminder = reminder;
            _followup = followup;
            _userid = uid;
        }

        public EventReminder(int index)
        {
            CreateEvent(index);
        }

        public int EventID
        {
            get { return _eventid; }
        }

        public DateTime ScheduledEvent
        {
            get { return _eventdate_time; }
            set { _eventdate_time = value; }
        }

        public string EventTitle
        {
            get { return _title; }
            set { _title = value; }
        }

        public string EventDescription
        {
            get { return _description; }
            set { _description = value; }
        }

        public string AddEmail
        {
            set { _emaillist.Add(value); }
        }

        public string EmailList
        {
            get
            {
                string dataline = "";
                foreach (string s in _emaillist)
                {
                    dataline += s + "|";
                }
                return dataline;
            }
        }

        public string Reminder
        {
            get { return _reminder; }
            set { _reminder = value; }
        }

        public bool EventFollowup
        {
            get { return _followup; }
            set { _followup = value; }
        }

        //remindersent next reminder

        public DateTime ReminderSent
        {
            get { return _remindersent; }
            set { _remindersent = value; }
        }

        public DateTime NextReminder
        {
            get { return _nextreminder; }
            set { _nextreminder = value; }
        }

        public int UserID
        {
            get { return _userid; }
        }

        private void CreateEvent(int index)
        {
            List<string> emaildata = new List<string>();
            
            switch (index)
            {
                case 1:
                    this._eventid = 1;
                    this._eventdate_time = DateTime.Parse("4/20/2012 05:20:00 PM");
                    this._title = "Test event one";
                    this._description = "Setup test on how this data needs to be setup.";
                    emaildata.Add("test@test.net");
                    this._emaillist = emaildata;
                    this._reminder = "?";
                    this._followup = false;
                    break;
                case 2:
                    this._eventid = 2;
                    this._eventdate_time = DateTime.Parse("4/20/2012 05:40:00 PM");
                    this._title = "Test event two";
                    this._description = "Setup test on how this data needs to be setup.";
                    emaildata.Add("test2@test.net");
                    this._emaillist = emaildata;
                    this._reminder = "?";
                    this._followup = false;
                    break;
                case 3:
                    this._eventid = 3;
                    this._eventdate_time = DateTime.Parse("4/20/2012 06:05:00 PM");
                    this._title = "Test event three";
                    this._description = "Setup test on how this data needs to be setup.";
                    emaildata.Add("test@test.net");
                    emaildata.Add("test3@test.net");
                    this._emaillist = emaildata;
                    this._reminder = "?";
                    this._followup = false;
                    break;
                default:
                    this._eventid = 0;
                    this._eventdate_time = DateTime.Now;
                    this._title = "";
                    this._description = "";
                    emaildata.Add("");
                    this._emaillist = emaildata;
                    this._reminder = "";
                    this._followup = false;
                    break;

            }
        }


    }
}
